Skip to content

test(pi): gate the installed Pi 1.0.0 RPC runtime [#639] - #646

Draft
zzwong wants to merge 2 commits into
zzwong/issue-638/pi-rpc-settlement-accountingfrom
zzwong/issue-639/pi-runtime-smoke
Draft

zzwong wants to merge 2 commits into
zzwong/issue-638/pi-rpc-settlement-accountingfrom
zzwong/issue-639/pi-runtime-smoke

Conversation

@zzwong

@zzwong zzwong commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #639. Stacked on #641; merge #641 first.

Summary

Most pi_rpc tests use a fake Pi, so they can miss changes in Pi's real contracts. Add credential-free installed-Pi tests and a pinned CI check. No production code changed.

  • New mock-provider cases use a fresh selected agent directory and HOME, offline flags, a dummy key, and loopback. Reviewer calls dispatch the real __pi-review-tool helper through TestMain.
  • Cover structured JSON, retry recovery, permanent errors, diff-first/path restrictions, read/search/list, exact usage/cache/cost totals, native-tool rejection, cancellation, and process-group cleanup.
  • Ordinary tests skip runtime cases when the opt-in is unset. The dedicated target requires the exact Makefile version, currently Pi 1.0.0; missing/wrong runtimes and blank pins fail.
  • Add non-required pi-runtime CI with pinned Node 22.22.3/action revisions and npm install --ignore-scripts. A failed version lookup stops before installation. Existing check identities remain unchanged.

Test plan

  • New retry/error/accounting tests fail against the pre-Fix Pi RPC completion handling and multi-turn usage accounting #638 adapter and pass here.
  • make test-pi-runtime passes on macOS and in a Linux arm64/root container; five repeated race runs pass.
  • Missing/wrong runtimes, empty/whitespace pins, and failed CI version lookup fail closed; focused Make guard regression passes.
  • GOFLAGS=-tags=keyring_nopassage go test ./..., Go 1.26.3 lint, actionlint, and git diff --check pass.
  • Confirm GitHub CI, including pi-runtime on x64/non-root.
  • Re-run the pinned target before future Pi/Node upgrades.

Limits

Evidence is local/mock, not deployed. Process-group assertions are Unix-only; Windows has no runtime coverage.

Hostile instructions at the default HOME location and in project resources are tested under a fresh selected agent directory. This does not establish production ambient-instruction isolation: selected-agent AGENTS.md affects non-reviewers, and APPEND_SYSTEM.md affects both modes. Follow-up #642 tracks that fix. Codemode remains separate in #640.

zzwong added 2 commits October 2, 2026 03:53
Most pi_rpc tests use a fake Pi, so they stay green when Pi's real
completion and event contracts drift. Add tests that run the adapter
against the installed Pi with an isolated agent directory and home,
offline mode, and a scripted loopback OpenAI-compatible provider with a
dummy key. Reviewer tool calls go through the real __pi-review-tool
helper, which TestMain dispatches the way the cr binary does.

The tests cover structured JSON without tools, a 503 followed by a
successful retry, permanent provider failures, a multi-turn reviewer run
with the diff-first gate, a path escape, and exact usage, cache, and cost
totals, a denied shell tool, and caller cancellation and task deadlines
with process-group cleanup. Hostile global and project instructions,
extensions, MCP servers, and skills must not load.

Ordinary go test skips them. make test-pi-runtime sets
CR_PI_RUNTIME_VERSION from the Makefile pin, so a missing or different
Pi fails. A new non-required pi-runtime CI job installs that version with
npm --ignore-scripts on pinned Node 22.22.3 and runs the target.
A blank PI_RUNTIME_VERSION made make test-pi-runtime export an empty
CR_PI_RUNTIME_VERSION, so every runtime test skipped and the target
reported ok. The same value made pi-runtime-version print nothing, which
the CI install step would turn into an unpinned, latest Pi install.

Both Make targets now require exactly one version word before doing
anything. The runtime tests also fail, rather than skip, when the opt-in
variable is set but blank. The CI step reads the version in its own
assignment so a failed lookup stops the step before npm runs.

A focused test runs both targets against a fake go and checks that blank,
whitespace, and multi-word pins fail without dispatching go test. The
development guide now states that the runtime fixture's isolation does
not extend to production agent directories (#642).
@zzwong
zzwong added this pull request to stack #647 October 3, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant